#ifndef __RTP_H
#define __RTP_H

#include <arpa/inet.h>
#include <iostream>

struct rtp_header
{
    uint8_t csrc_num : 4;
    uint8_t extension : 1;
    uint8_t padding : 1;
    uint8_t version : 2;
    uint8_t payload_type : 7;
    uint8_t marker : 1;
    uint16_t sequence;
    uint32_t timestamp;
    uint32_t ssrc;
};

class RtpEmitter
{
public:
    RtpEmitter(uint16_t self_port, const char *target_ip, uint16_t target_port, uint8_t ptype);
    ~RtpEmitter();

    void send_nalu(const char *nalu, size_t nalu_len, bool islast);

    void send_adts(const char *adts_raw, size_t len, bool islast);

private:
    int _socket;
    sockaddr_in _target_adr;
    rtp_header _rtpheader;
};

#endif